package leetcode_core.leetcode_4;

import java.util.List;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2022年10月29日 9:11
 */
public class CountMatches {
    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {
        int chose = 0;
        if(ruleKey.equals("type")){
            chose = 0;
        } else if(ruleKey.equals("color")){
            chose = 1;
        } else if(ruleKey.equals("name")){
            chose = 2;
        }
        int cnt = 0;
        for (List<String> item : items) {
            if(item.get(chose) == ruleValue){
                cnt++;
            }
        }
        return cnt;
    }
}
